<template>
    <div>
        <!-- 根据条件查询 -->
        <div>
            <el-form :inline="true" :model="formInline" class="demo-form-inline" ref="ruleForm">
                <el-form-item label="单据编号">
                    <el-input v-model="documentsNumber" placeholder="请输入单据编号查询"></el-input>
                </el-form-item>
                <el-form-item label="商品信息">
                    <el-input v-model="productName" placeholder="请输入商品信息查询"></el-input>
                </el-form-item>
                <el-form-item label=" 单据日期 ">
                    <el-date-picker
                        v-model="begintime"
                        type="datetimerange"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期"
                        :default-time="['12:00:00']"/>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="getSalesOrderList">查询</el-button>
                    <el-button @click="resetForm">重置</el-button>
                </el-form-item>
            </el-form>
        </div>
        <!-- table展示 -->
        <div>
            <div style="margin-top: 20px;">
                <el-button type="primary" @click="addSalesOrder1" ><Icon type="md-add" /> 添加</el-button>
                <el-dropdown split-button type="primary" style="padding-left:20px" v-show="this.xlk">
                    批量操作
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                    <Icon type="ivu-icon ivu-icon-ios-checkmark-circle-outline"/>
                    <span @click="shenhe">审核</span>
                    </el-dropdown-item>
                    <!-- <el-dropdown-item>
                    <Icon type="ios-close"/>
                    <span @click="fanshenhe">反审核</span>
                    </el-dropdown-item> -->
                    <el-dropdown-item>
                    <Icon type="ios-add" />
                    <span @click="addSalesOrder2">继续添加</span>
                    </el-dropdown-item>
                    <!-- <el-dropdown-item>
                <Icon type="ios-color-wand" />
                    <span @click="fanshenhe">编辑</span>
                    </el-dropdown-item> -->
                </el-dropdown-menu>
                </el-dropdown>
            </div>
            <br>
            <Table
            border
            ref="selection"
            :columns="columns4"
            :data="data1"
            @on-selection-change="select2">

            <template slot-scope="row" slot="action">
                <Button type="info" size="large" @click="findSalesOrderByDCNum(row)">查看</Button>
            </template>

            <!-- <template slot-scope="{ row, index }" slot="action">
                <Button type="info" size="large" @click="findSalesOrderByDCNum(row)">查看</Button>
            </template> -->

            <!-- <template slot-scope="{ row, index }" slot="status3">
            <el-tag type="warning">{{row.status3==1?"零售":"批发"}}</el-tag>
            </template> -->

            <template slot-scope="scope" slot="status2">
                <el-tag :type="scope.row.erpState.stateName==='审核'? 'primary':'danger'" >
                    {{scope.row.erpState.stateName=='审核'?"审核":"未审核"}}
                </el-tag>
            </template>
        </Table>
        <br>
        <!-- 分页 -->
        <div style="float:right"><!-- changepage分页页码回调，_nowPageSize分页条数回调 -->
            <Page
            :total="dataCount"
            :page-size="pageSize"
            @on-change="changepage" 
            @on-page-size-change="_nowPageSize"
            show-elevator/>
        </div>
        <!-- 根据订单编号查看 -->
        <Modal v-model="findSalseDMNumContent" title="查看" @on-ok="okDM" @on-cancel="cancelDM" width="1340">
        <Table border ref="selection" :columns="columns5" :data="DMNumList">
            <template slot-scope="row" slot="resName">{{row.row.erpWarehouseinformation.resName}}</template>

            <template slot-scope="row" slot="upd">
                <Button type="info" size="large" @click="preUpdEnterOById(row.row)">修改</Button>
            </template>

            <template slot-scope="row" slot="del">
                <Button type="info" size="large" @click="predelEnterCommodityContentByid(row.row)">删除</Button>
            </template>

        </Table>
        </Modal>

        <!-- 修改的弹出框 -->
        <Modal
            width="1000"
            v-model="updS"
            title="修改"
            @on-ok="updEnterOById"
            >
            <el-form :inline="true" :model="EnterOrderContent2" class="demo-form-inline">
                <el-form-item label="单据编号:">
                    <el-input v-model="EnterOrderContent2.documentsNumber" disabled></el-input>
                </el-form-item>     
                <el-form-item label="仓库:">
                    <el-input v-model="EnterOrderContent2.resName" disabled></el-input>
                </el-form-item> 
                <el-form-item label="条码:">
                    <el-input v-model="EnterOrderContent2.barCode" disabled></el-input>
                </el-form-item>
                <br>
                <el-form-item label="商品名称:">
                    <el-input v-model="EnterOrderContent2.productName" disabled></el-input>
                </el-form-item>
                <el-form-item label="数量:">
                    <el-input v-model="EnterOrderContent2.number"></el-input>
                </el-form-item> 
                <el-form-item label="单价:">
                    <el-input v-model="EnterOrderContent2.unitPrice"></el-input>
                </el-form-item>   
            </el-form>
        </Modal>

        <!-- 添加采购订单-详情form -->
        <div>
        <Modal v-model="addSalesOrder" title="新增订单" @on-ok="ok" @on-cancel="cancel" width="1355">
            <div>
            <el-form :inline="true" :model="ErpEnterOrder" class="demo-form-inline">

                <el-form-item label="操作人员:">
                        <el-input v-model="this.userName" disabled></el-input>
                </el-form-item>

            
                <el-form-item label="单据日期:">
                <div class="block">
                    <el-date-picker v-model="this.addForm.createDate" type="datetime" placeholder="选择日期时间"  
                    format="yyyy 年 MM 月 dd 日  HH时 mm分  ss秒"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    ></el-date-picker>
                </div>
                </el-form-item>


                <el-form-item label="*供应商:">
                <el-select v-model="ErpEnterOrder.supplier" placeholder="供应商">
                    <el-option v-for="item in provider" :label='item.supplierName' :value='item.supplierName' :key="item.id"></el-option>
                </el-select>
                </el-form-item>

    
                <el-form-item label="取货地址:">
                        <el-input v-model="ErpEnterOrder.salesLocation" ></el-input>
                </el-form-item>
                <br>

                <el-form-item label="单据编号:">
                <el-input v-model="this.documentsNumber2"  disabled=""></el-input>
                </el-form-item>   

                <el-form-item label="银行卡号:">
                <el-select  placeholder="请选择银行卡号"  v-model="ErpEnterOrder.types">
                    <el-option v-for="item in ErpSettlementaccount" :label="item.accountNumber" :value="item.id" :key="item.id"></el-option>
                    <!-- <el-option v-for="item in bankCard" :label='item.accountBank' :value='item.id' :key="item.id"></el-option>
                    <el-option label="支付宝" value="支付宝"></el-option>
                    <el-option label="微信" value="微信"></el-option>
                    <el-option label="银行卡" value="银行卡"></el-option> -->
                </el-select>
                </el-form-item>
                <!-- <el-form-item label="开户银行::">
                    <el-input v-model="this.SettlementaccountNum"  disabled=""></el-input>
                </el-form-item> -->
            </el-form>

                <br>


            <!-- 添加采购订单具体内容 -->
            <el-form ref="ErpEnterContent" :model="ErpEnterContent" label-width="100px">
                <div style="border-left: 4px solid #39a9ff;padding-left: 8px;line-height: initial;font-size: initial;">
                <h4>采购订单具体内容</h4>
                </div>
                <br><br>
                <el-row :gutter="20">
                    <el-col :span="7">
                    <el-form-item label="商品类型:" >
                        <el-select v-model="ErpEnterContent.type" placeholder="请选择商品类型" @change="selectGet">
                        <el-option v-for="item in styleComm" :label="item.classificationName" :value="item.id" :key="item.id" ></el-option>
                        </el-select>

                        <!-- 13 -->
                    </el-form-item>
                    </el-col>

                    <el-col :span="7">
                    <el-form-item label="商品名称:" >
                        <el-select v-model="ErpEnterContent.productName" placeholder="请选择商品"  @change="selectGet2">
                            <el-option v-for="item in alreadystorageList" :label="item.productName" :value="item.productName" :key="item.id" ></el-option>
                        </el-select>
                    </el-form-item>
                    </el-col>

                    <el-col :span="7">
                    <el-form-item label="商品数量:" >
                        <el-input v-model="ErpEnterContent.number"></el-input>
                    </el-form-item>
                    </el-col>
                </el-row>

                <!-- 第二行 -->
                <el-row :gutter="20">
                    <el-col :span="7">
                    <el-form-item label="商品型号:" >
                        <el-input v-model="ErpEnterContent.model" disabled=""></el-input>
                    </el-form-item>
                    </el-col>
                    <el-col :span="7">
                    <el-form-item label="商品单位:" >
                        <el-input v-model="ErpEnterContent.unit" disabled=""></el-input>
                    </el-form-item>
                    </el-col>
                
                    <el-col :span="7">
                    <el-form-item label="最低售价:" >
                        <el-input v-model="ErpEnterContent.lowestPrice"  disabled=""></el-input>
                    </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="20">
                    <el-col :span="7">
                    <el-form-item label="仓库所在地:" >
                        <el-select v-model="ErpEnterContent.resName" placeholder="仓库" disabled="">
                            <el-option :label="ErpEnterContent.resName" :value="ErpEnterContent.wid" ></el-option>
                        </el-select>
                    </el-form-item>
                    </el-col>
                    <el-col :span="7">
                    <el-form-item label="商品单价:" >
                        <el-input v-model="ErpEnterContent.unitPrice"></el-input>
                    </el-form-item>
                    </el-col>
                    <el-col :span="7">
                    <el-form-item label="市场价格" >
                        <el-input v-model="ErpEnterContent.sellingPrice" disabled=""></el-input>
                    </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            </div>
        </Modal>
        </div>
        </div>

        <!-- 再次添加采购详情 -->
        <div>
      <Modal v-model="addSalesOrderContent" title="新增订单" @on-ok="addSalesOrderOK" @on-cancel="addSalesOrdercancal" width="1355">
        <div>
          <el-form :inline="true" :model="ErpEnterOrder" class="demo-form-inline">

            <el-form-item label="操作人员:">
                    <el-input v-model="this.salesOrderById.operator" disabled=""></el-input>
            </el-form-item>

           
             <el-form-item label="单据日期:">
              <div class="block">
                <el-date-picker v-model="this.salesOrderById.documentDate" type="datetime" placeholder="选择日期时间"  
                format="yyyy 年 MM 月 dd 日  HH时 mm分  ss秒"
                value-format="yyyy-MM-dd HH:mm:ss"
                @on-change="this.salesOrderById.documentDate=$event"
                time-zone="GMT+8"></el-date-picker>
              </div>
            </el-form-item>


             <el-form-item label="供应商:">
                   <el-input v-model="this.salesOrderById.supplier" disabled=""></el-input>
        
            </el-form-item>

            <el-form-item label="单据编号:">
              <el-input v-model="this.salesOrderById.documentsNumber"  disabled=""></el-input>
            </el-form-item>   

          </el-form>
        <br>
          <!-- 添加销售订单具体内容 -->
          <el-form ref="ErpEnterContent" :model="ErpEnterContent" label-width="100px">
            <div style="border-left: 4px solid #39a9ff;padding-left: 8px;line-height: initial;font-size: initial;">
              <h4>采购订单具体内容</h4>
            </div>
            <br><br>
              <el-row :gutter="20">
                <el-col :span="7">
                  <el-form-item label="商品类型:" >
                    <el-select v-model="ErpEnterContent.type" placeholder="请选择商品类型" @change="selectGet">
                      <el-option v-for="item in styleComm" :label="item.classificationName" :value="item.id" :key="item.id"></el-option>
                    </el-select>

                    <!-- 13 -->
                  </el-form-item>
                </el-col>

                <el-col :span="7">
                  <el-form-item label="商品名称:" >
                    <el-select v-model="ErpEnterContent.productName" placeholder="请选择商品"  @change="selectGet2">
                        <el-option v-for="item in alreadystorageList" :label="item.productName" :value="item.productName" :key="item.id"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>

                <el-col :span="7">
                  <el-form-item label="商品条码:" >
                    <el-input v-model="ErpEnterContent.barCode"  disabled=""></el-input>
                  </el-form-item>
                </el-col>
              </el-row>

              <!-- 第二行 -->
              <el-row :gutter="20">
                <el-col :span="7">
                  <el-form-item label="商品型号:" >
                    <el-input v-model="ErpEnterContent.model" disabled=""></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="7">
                  <el-form-item label="商品单位:" >
                    <el-input v-model="ErpEnterContent.unit" disabled=""></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="7">
                  <el-form-item label="商品数量:" >
                    <el-input v-model="ErpEnterContent.number" ></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="20">
                <el-col :span="7">
                  <el-form-item label="仓库所在地:" >
                    <el-select v-model="ErpEnterContent.wid" placeholder="仓库" disabled="">
                        <el-option :label="ErpEnterContent.resName" :value="ErpEnterContent.wid" ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="7">
                  <el-form-item label="商品单价:" >
                    <el-input v-model="ErpEnterContent.unitPrice"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="7">
                  <el-form-item label="序列号:" >
                    <el-input v-model="ErpEnterContent.documentsNumber" disabled=""></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
          </el-form>
        </div>
      </Modal>
        </div>

        <!-- 采购详情 -- 删除 -->
        <Modal
            v-model="delmodal"
            title="警告"
            
            @on-ok="delSalesOrderContentByid">
            <p>确定要删除吗?</p>
        </Modal>



    </div>
</template>
<script>
import axios from "axios"
export default {
    data(){
        return{
            //修改
            EnterOrderContent2:{},

            //修改对话框
            updS:false,

            //对话框
            delmodal:false,

            //保存删除的id 和 编码
            delId:"",
            DNumber:"",


            //接收根据id查询的salseOrder
            salesOrderById:{},


            //封装了已经入库的内容
            alreadystorageList:[],

            //销售订单的对象
            ErpEnterOrder:{},

            //销售订单内容的数组
            ErpSalescontentArr:[
                
            ],
            
            //默认时间
            addForm:{
                createDate:new Date()
            },


            //供应商list
            provider:[],

            //刷新
            spinShow:true,


            pageSize: 5, //每页显示多少条
            dataCount: 0, //总条数
            pageCurrent: 1, //当前页,
            width: 100,

            // 分页的条件
            productName: "",
            documentsNumber: "",
            begintime: [],

            // 销售人员 -- 没有
            userName:"",

            //商品类型
            styleComm: [],

            //单据编号
            documentsNumber2:"",

            // table多选框的值
            tableSelection: [],

            //隐藏的下拉框
            xlk: false,

            //购房人基本信息属性
            ErpEnterContent: {
            //     erpWarehouseinformation:{
                
            // },
                resName:"",
                documentsNumber: "",
                productName: "",
                wid: "",
                unit: "",
                serialNumber:"",
                model: "",
                type: "",
                productNumber: "", // 无
                extendedInformation:"",
                number: "",
                barCode: "",
                unitPrice: "",
                sellingPrice:"",
                lowestPrice:"",
            },

            // 88888
            columns5: [
                {
                title: "单据编号",
                key: "documentsNumber"
                },
                {
                title:"序列号",
                key:"serialNumber"
                },
                {
                title: "商品名称",
                key: "productName"
                },
                {
                title:"数量",
                key:"number"
                },
                {
                title:"单价",
                key:"unitPrice"
                },
                {
                title:"总价",
                key:"totalAmount"
                },
                {
                title: "仓库",
                slot: "resName"
                },
                {
                title:"操作",
                slot:"upd"
                },
                {
                title:"删除",
                slot:"del"
                }
            ],
            DMNumList: [],

            columns4: [
                {
                type: "selection",
                width: 60,
                align: "center"
                },
                {
                title: "#",
                key: "id"
                },
                {
                title: "供应商",
                key: "supplier"
                },
                {
                title: "单据编号",
                key: "documentsNumber"
                },
                {
                title: "商品信息",
                key: "productName"
                },
                {
                title: "单据日期",
                key: "documentDate"
                },
                {
                title: "操作员",
                key: "operator"
                },
                {
                title: "金额合计",
                key: "totalAmount"
                },
                {
                title: "状态(是否销售)",
                slot: "status2"
                },
                // {
                //   title: "状态2(零售/批发)",
                //   slot: "status3"
                // },
                {
                title: "用户操作",
                slot: "action"
                }
            ],
            data1: [],
            addSalesOrder: false,
            addSalesOrderContent: false,
            findSalseDMNumContent: false,

            formInline: {
                user: "",
                region: ""
            },

            //结算账户的卡
            ErpSettlementaccount:[],
            SettlementaccountNum:"",

            value1: "",
            value2: "",
            solesOrder: {}
        };
    },

    // 挂载
    created() {
        this.getSalesOrderList();
        this.getErpCustomerinformationList();
        this.getCommodityStyleList2();
        this.findErpSettlementaccountList();
    },

    methods: {
        
        //支付类型下拉框选中事件
        selectType(value){
            console.log(value)
            for(var i=0;i<this.ErpSettlementaccount.length;i++){
            if(value==this.ErpSettlementaccount[i].id){
                this.SettlementaccountNum=this.ErpSettlementaccount[i].accountName
            }
            }
            console.log(this.SettlementaccountNum)
        },


        //查询所以结算账户的卡
        findErpSettlementaccountList(){
        axios.post("//localhost:8082/entercommodity/findErpSettlementaccountList").then(res=>{
            this.ErpSettlementaccount=res.data;
            console.log("00000000000000000000000")
            console.log(this.ErpSettlementaccount)
        })

        },

        //查找商品类型List
        getCommodityStyleList2(){
            axios
            .post(
            "//localhost:8082/commodity/getCommodityStyleList"
            )
            .then(res => {
            console.log(res.data)
            this.styleComm=res.data;
            console.log(this.styleComm)
            });
        },

        
        //点击下拉框的值  触发事件  获取已经添加的商品list
        selectGet(vId){
            let obj = {};
            obj=this.styleComm.find((item)=>{
                return item.id===vId
            })
            console.log(obj.id)
            axios.post("//localhost:8082/commodity/getCommByTypes?types="+obj.id).then(
                res=>{
                    console.log(res)
                    this.alreadystorageList=res.data;
                    console.log(res.data)
                }
            )
        },

        //点击下拉框的值  触发事件  将一条数据赋值给各个input
        selectGet2(name){

            let obj = {};
            //循环判断
            obj=this.alreadystorageList.find((item)=>{
                return item.productName===name
            })
            console.log("****下拉框*******")
            console.log(obj)
            //赋值
                this.ErpEnterContent.resName=obj.erpWarehouseinformation.resName
                this.ErpEnterContent.wid=obj.wid
                this.ErpEnterContent.documentsNumber=obj.documentsNumber //商品编号
                this.ErpEnterContent.specification = obj.specification // 供应商
                this.ErpEnterContent.extendedInformation = obj.extendedInformation; // 扩展信息
                this.ErpEnterContent.unit=obj.unitList.basicUnit // 单位
                this.ErpEnterContent.serialNumber = obj.serialNumber
                    this.ErpEnterContent.model=obj.model
                    this.ErpEnterContent.productName=obj.productName
                    this.ErpEnterContent.number=obj.num
                        this.ErpEnterContent.barCode=obj.barcode
                            this.ErpEnterContent.unitPrice=obj.purchasePrice
                            this.ErpEnterContent.sellingPrice=obj.sellingPrice
                            this.ErpEnterContent.lowestPrice=obj.lowestPrice
        },

        //查询供应商信息
        getErpCustomerinformationList(){
            axios
            .post(
            "//localhost:8082/supplierinformation/getErpSupplierinformationList"
            )
            .then(res => {
            console.log("--------**********------------")
            console.log(res)
            this.provider=res.data;
            console.log(this.provider)
            });
        },

        // 查找所有销售订单的信息   // 分页
        getSalesOrderList() {
            axios
            .post(
            "//localhost:8082/entercommodity/getPageByEnterOrder1?documentsNumber=" +
                this.documentsNumber +
                "&productName=" +
                this.productName +
                "&time=" +
                this.begintime +
                "&pageSize=" +
                this.pageSize + 
                "&pageCurrent=" +
                this.pageCurrent
            )
            .then(res => {
            // console.log(res.data);
            this.xlk = false;
            this.dataCount = res.data.countTotal;
            this.data1 = res.data.list;
            console.log(this.data1)
            console.log(this.begintime + "事件123");
            //当从数据库获取完毕  关闭加载特效
            this.spinShow=false;
            // this.begintime = "";
            });
        },

        // 根据单据编号查询
        findSalesOrderByDCNum(row) {
            axios
            .get(
            "http://localhost:8082/enterCommditycontent/getEntercommoditycontentByDCNum?documentNumber=" +
                row.row.documentsNumber
            )
            .then(res => {
            this.DMNumList = res.data;
            console.log(this.DMNumList)
            console.log("------********-------")
            this.findSalseDMNumContent = true;
            });
        },

        //点击这个,即可换页数
        changepage(index) {
            axios
            .get(
            "http://localhost:8082/entercommodity/getPageByEnterOrder1?documentsNumber=" +
                this.documentsNumber +
                "&productName=" +
                this.productName +
                "&time=" +
                this.begintime +
                "&pageSize=" +
                this.pageSize +
                "&pageCurrent=" +
                index
            )
            .then(response => {
            this.dataCount = response.data.countTotal;
            this.data1 = response.data.list;
            });
        },

        //每页显示的数据条数
        _nowPageSize(index) {
            //实时获取当前需要显示的条数
            this.pageSize = index;
        },


        // 添加销售订单的内容  第一条
        addSalesOrder1(){
            //当点击一次添加   自动更新一次订单编号
            this.documentsNumber2='AX'+this.getProjectNum()+Math.floor(Math.random() * 10000);
            //从session中获取session
            this.userName = sessionStorage.getItem("user");
            //是model展示出来   默认false
            this.ErpEnterOrder = {}
            this.ErpEnterContent = {}
            this.addSalesOrder=true;
        },


        //继续添加销售订单的内容  第二条 第三条等
        addSalesOrder2(){
            console.log(this.tableSelection[0])
            if(this.tableSelection.length==1){
            var id="";
            id=this.tableSelection[0].id
            //根据id查询出
            axios.post("http://localhost:8082/entercommodity/selectEnterCommoById?id="+id).then(res=>{
                //根据id查询出来销售订单  赋值
                this.salesOrderById=res.data;
            })
            //打开弹框
            this.ErpEnterContent = {}
            this.addSalesOrderContent=true;
            }else{
            this.$notify.info({
            title: '消息',
            message: '请选择一条内容进行添加'
            });
            }
        },

        onSubmit() {
            axios
            .post(
            "http://localhost:8082/salesOrder/aaa?documentsNumber=" +
                this.documentsNumber +
                "&productName=" +
                this.productName +
                "&time=" +
                this.begintime
            )
            .then(response => {
            console.log(this.begintime);
            });
        },
        resetForm(formName) {
            this.$refs[formName].resetFields();
        },
        toggleSelection(rows) {
            if (rows) {
                rows.forEach(row => {
                this.$refs.multipleTable.toggleRowSelection(row);
                });
            } else {
                this.$refs.multipleTable.clearSelection();
            }
        },
        //新增购房人基本信息
        addBuyerInformation() {
            const that = this;
            that.basicInformation.purPeoList.push({});
        },
        //删除购房人基本信息
        removeRow(index) {
            if (index >= 0) {
                this.basicInformation.purPeoList.splice(index, 1);
            }
        },

        // 添加销售订单和销售订单的
        ok() {
            this.ErpEnterOrder.operator=this.userName;
            this.ErpEnterOrder.documentsNumber=this.documentsNumber2;
            this.ErpEnterOrder.documentDate=this.addForm.createDate;
            console.log(this.ErpEnterOrder)
            console.log(this.ErpEnterContent)
            axios.post("//localhost:8082/entercommodity/addEnterOrderAndContent?operator="+this.userName+"&documentDate="+this.addForm.createDate
                +"&enterAddress="+this.ErpEnterOrder.salesLocation+"&documentsNumber="+this.documentsNumber2+"&buyTypes="+this.ErpEnterOrder.types
                +"&supplier="+this.ErpEnterOrder.supplier, this.ErpEnterContent).then(res=>{
            if(res.data=="ok"){
                //刷新
                this.getSalesOrderList();
                this.$notify({
                    title: '成功',
                    message: '恭喜你,添加成功666',
                    type: 'success'
                });
            }else{
                this.$notify({
                    title: '警告',
                    message: res.data,
                    type: 'warning'
                });
            }
            
        })

        
        },

        cancel() {
            this.$notify({
            title: '警告',
            message: '已取消添加',
            type: 'warning'
            });
        },


        //继续添加销售订单的商品内容  
        addSalesOrderOK(){
            axios.post("//localhost:8082/entercommodity/addEnterOrderAndContent2?documentsNumber="+
            this.salesOrderById.documentsNumber,this.ErpEnterContent).then(res=>{
                if(res.data=="ok"){
                    //刷新
                    this.getSalesOrderList();
                    this.$notify({
                        title: '成功',
                        message: '恭喜你,添加成功666',
                        type: 'success'
                    });
                }else{
                    this.$notify({
                        title: '警告',
                        message: '商品数量不足或商品低于最低销售价格无法添加!',
                        type: 'warning'
                    });
                }
            })
        
        },



        //取消按钮
        addSalesOrdercancal(){
        this.$notify({
                title: '警告',
                message: '已取消添加',
                type: 'warning'
            });
        },


        //查看销售订单具体内容   确定按钮
        okDM(){
            // this.$notify({
            //   title: '成功',
            //   message: '恭喜你,查看成功',
            //   type: 'success'
            // });
        },
        //查看销售订单   取消按钮
        cancelDM(){
        // this.$notify({
        //     title: '警告',
        //     message: '已取消查看',
        //     type: 'warning'
        //   });
        },


    
        // 重置
        resetForm() {
            this.documentsNumber = "";
            this.begintime = [];
            this.productName = "";
        },

        // 当选中的时候触发   没有选中不触发
        select2(rows) {
            this.tableSelection = [];
            this.tableSelection = rows;
            console.log(this.tableSelection);
            this.xlk = true;
            if (this.tableSelection.length == 0) {
                this.xlk = false;
            }
        },

        // 审核
        shenhe() {
                if(this.tableSelection.length==1){
                //创建一个数组
                let ids = [];
                //赋值
                this.tableSelection.forEach(function(e) {
                    ids.push(e.id);
                });
                
                this.$confirm('确定启用吗?, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                    }).then(() => {
                        //当点击确定  开始加载特效
                        this.spinShow=true;
                        //跨域
                        axios.post("http://localhost:8082/entercommodity/updateEnterCommById?id="+ ids[0])
                        .then(res => {
                        if(res.data=="ok"){
                        //成功的提示
                                this.$notify({
                                title: '启用成功',
                                message: '恭喜你启用成功',
                                type: 'success'
                            });
                        }else{
                            this.$notify.error({
                            title: '错误',
                            message: '审核之前请认真查看该订单的商品!'
                            });
                        }
                        
                        //刷新
                        this.getSalesOrderList();   
                        //当启用成功以后  结束加载特效
                        this.spinShow=false;     
                        });

                    this.getSalesOrderList();
                    }).catch(() => {
                    this.$notify({
                    title: '取消审核',
                    message: '恭喜你取消审核成功',
                    type: 'warning'
                    });        
                    });
                }else{
                this.$notify.info({
                title: '消息',
                message: '请选择一条内容进行添加'
                });
            }
        
        },



        //反审核
            fanshenhe() {
            if(this.tableSelection.length==1){
    //创建一个数组
        let ids = [];
        //赋值
        this.tableSelection.forEach(function(e) {
            ids.push(e.id);
        });
        console.log(ids);
        this.$confirm('确定禁用吗?, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
            }).then(() => {
            //当点击确定  开始加载特效
            this.spinShow=true;
            //跨域
                axios.post("http://localhost:8082/entercommodity/updateEnterCommByIdF?id="+ ids[0])
                .then(res => {
                //成功的提示
                this.$notify({
            title: '禁用成功',
            message: '恭喜你禁用成功',
            type: 'success'
            });
            //刷新
                this.getSalesOrderList();   
                //当启用成功以后  结束加载特效
                this.spinShow=false;     
                });
    this.getSalesOrderList();
            }).catch(() => {
            this.$notify({
            title: '取消审核',
            message: '恭喜你取消反审核成功',
            type: 'warning'
            });        
            });
                }else{
    this.$notify.info({
            title: '消息',
            message: '请选择一条内容进行添加'
            });
                }
        
        },


        //生成单据编号
        // 获取当前日期的方法
            getProjectNum () {
        const projectTime = new Date() // 当前中国标准时间
        const Year = projectTime.getFullYear() // 获取当前年份 支持IE和火狐浏览器.
        const Month = projectTime.getMonth() + 1 // 获取中国区月份
        const Day = projectTime.getDate() // 获取几号
        var CurrentDate = Year
        if (Month >= 10) { // 判断月份和几号是否大于10或者小于10
            CurrentDate += Month
        } else {
            CurrentDate += '0' + Month
        }
        if (Day >= 10) {
            CurrentDate += Day
        } else {
            CurrentDate += '0' + Day
        }
        return CurrentDate+1
    },


        //预删除
        predelEnterCommodityContentByid(row){
            // console.log("--------------------")
            // console.log(row)
            this.delId=row.id;
            this.DNumber = row.documentsNumber
            this.delmodal=true;

        // axios.post("http://localhost:8082/salesOrderContent/delSalesOrderContentById?id="+row.id).then(res=>{
        //   console.log(row)
        // })
        },

    //删除销售订单的商品
        delSalesOrderContentByid(){
            axios.post("http://localhost:8082/enterCommditycontent/deleteERPEnterCC?id="+this.delId+"&DNamber="+this.DNumber).then(res=>{
                // console.log(row)
                this.spinShow=true;
                this.findSalseDMNumContent=false;
                this.getSalesOrderList();
                this.spinShow=false;
            })
        },


        //预修改
        preUpdEnterOById(row){
        this.EnterOrderContent2=row;
        console.log(row);
        this.EnterOrderContent2.resName=row.erpWarehouseinformation.resName
        console.log(this.EnterOrderContent2)
        this.findSalseDMNumContent=false;
        this.updS=true;
        },


        //修改
        updEnterOById(){
        axios.post("http://localhost:8082/enterCommditycontent/updateERPEnterCC",this.EnterOrderContent2).then(res=>{
            console.log("||||||||||||||")
            console.log(res)
            if(res.data=="ok"){
            this.$notify({
            title: '成功',
            message: '修改成功',
            type: 'success'
            
            });
            this.getSalesOrderList();
                }else{
            this.$notify.error({
            title: '错误',
            message: '修改失败'
            });
            }
            })
        }
    }
};
</script>
